<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>请假单</title>
    <script src="/js/common.js"></script>
    <script src="/js/dateutil.js"></script>
</head>
<body>

<form action="/vacation/add" id="form" method="post" enctype="multipart/form-data" >
    <p>请假类型：
        <select name="vacationTypeId">
            <option th:each="type : ${vacationTypeList}" th:text="${type.vacationType}" th:value="${type.vacationTypeId}"></option>
        </select>
    </p>
    <p>开始时间：<input type="date" id="vacationStartTime" name="vacationStartTime"></p>
    <p>结束时间：<input type="date" id="vacationEndTime" name="vacationEndTime"></p>
    <p>手机号码：<input type="text" id="cellPhone" name="cellPhone"></p>
    <p>备注：<input type="text" name="remark"></p>
    <p>审批照片：<input type="file" name="file"></p>
    <p><input type="button" onclick="doSubmit()" value="提交"></p>

</form>

</body>
<script>
    function doSubmit(){
        // alert('提交')
        var formObj = document.getElementById("form");
        var cellPhoneObj = document.getElementById("cellPhone");
        //验证手机号码
        if(!isPhoneAvailable(cellPhoneObj.value)){
            alert('手机号码格式错误！')
            return ;
        }

        var vacationStartTimeObj = document.getElementById("vacationStartTime");
        var vacationEndTimeObj = document.getElementById("vacationEndTime");



        var vacationStartTimeStr=vacationStartTimeObj.value;//开始时间
        var vacationEndTimeStr=vacationEndTimeObj.value;//结束时间


        var currentTime = new Date();
        var currentTimeStr = currentTime.Format("yyyy-MM-dd");

        if(vacationStartTimeStr<=currentTimeStr){
            alert('开始时间必须大于系统当前时间')
            return;
        }
        if(vacationStartTimeStr>=vacationEndTimeStr){
            alert('开始时间必须小于结束时间')
            return;
        }

        formObj.submit();
    }
</script>



</html>